<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>SoapClient constructor</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="soapclient.soapcall.html">SoapClient::__soapCall</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.soapserver.html">SoapServer</a></div>
 <div class="up"><a href="class.soapclient.html">SoapClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="soapclient.soapclient" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SoapClient::SoapClient</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.1)</p><p class="refpurpose"><span class="refname">SoapClient::SoapClient</span> &mdash; <span class="dc-title">SoapClient constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-soapclient.soapclient-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SoapClient::SoapClient</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$wsdl</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   This constructor creates <a href="class.soapclient.html" class="classname">SoapClient</a> objects 
   in <em>WSDL</em> or <em>non-WSDL</em> mode.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-soapclient.soapclient-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">wsdl</code></em></dt>

     <dd>

      <p class="para">
       URI of the <em>WSDL</em> file or <strong><code>NULL</code></strong> if working in 
       <em>non-WSDL</em> mode.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        During development, WSDL caching may be disabled by the
        use of the <em>soap.wsdl_cache_ttl</em> <var class="filename">php.ini</var> setting
        otherwise changes made to the WSDL file will have no effect until
        <em>soap.wsdl_cache_ttl</em> is expired. 
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       An array of options. If working in WSDL mode, this parameter is optional.
       If working in non-WSDL mode, the <em>location</em> and 
       <em>uri</em> options must be set, where <em>location</em>
       is the URL of the SOAP server to send the request to, and <em>uri</em>
       is the target namespace of the SOAP service.
      </p>
      <p class="para">
       The <em>style</em> and <em>use</em> options only work in
       non-WSDL mode. In WSDL mode, they come from the WSDL file.
      </p>
      <p class="para">
       The <em>soap_version</em> option should be one of either
       <strong><code>SOAP_1_1</code></strong> or <strong><code>SOAP_1_2</code></strong> to
       select SOAP 1.1 or 1.2, respectively. If omitted, 1.1 is used.
      </p>
      <p class="para">
       For HTTP authentication, the <em>login</em> and
       <em>password</em> options can be used to supply credentials. 
       For making an HTTP connection through
       a proxy server, the options <em>proxy_host</em>,
       <em>proxy_port</em>, <em>proxy_login</em>
       and <em>proxy_password</em> are also available.
       For HTTPS client certificate authentication use
       <em>local_cert</em> and <em>passphrase</em> options. An 
       authentication may be supplied in the <em>authentication</em> 
       option. The authentication method may be either 
       <strong><code>SOAP_AUTHENTICATION_BASIC</code></strong> (default) or 
       <strong><code>SOAP_AUTHENTICATION_DIGEST</code></strong>.
      </p>
      <p class="para">
       The <em>compression</em> option allows to use compression
       of HTTP SOAP requests and responses.
      </p>
      <p class="para">
       The <em>encoding</em> option defines internal character 
       encoding. This option does not change the encoding of SOAP requests (it is
       always utf-8), but converts strings into it.
      </p>
      <p class="para">
       The <em>trace</em> option enables tracing of request so faults 
       can be backtraced. This defaults to <strong><code>FALSE</code></strong>
      </p>
      <p class="para">
       The <em>classmap</em> option can be used to map some WSDL 
       types to PHP classes. This option must be an array with WSDL types 
       as keys and names of PHP classes as values.
      </p>
      <p class="para">
       Setting the boolean <em>trace</em> option enables use of the
       methods <a href="soapclient.getlastrequest.html" class="link">
       SoapClient-&gt;__getLastRequest</a>, 
      <a href="soapclient.getlastrequestheaders.html" class="link">
       SoapClient-&gt;__getLastRequestHeaders</a>,
       <a href="soapclient.getlastresponse.html" class="link">
       SoapClient-&gt;__getLastResponse</a> and
       <a href="soapclient.getlastresponseheaders.html" class="link">
       SoapClient-&gt;__getLastResponseHeaders</a>.
      </p>
      <p class="para">
       The <em>exceptions</em> option is a boolean value defining whether
       soap errors throw exceptions of type <a href="soapfault.soapfault.html" class="link">
       SoapFault</a>.
      </p>
      <p class="para">
       The <em>connection_timeout</em> option defines a timeout in seconds 
       for the connection to the SOAP service. This option does not define a timeout
       for services with slow responses. To limit the time to wait for calls to finish the 
       <a href="filesystem.configuration.html#ini.default-socket-timeout" class="link">default_socket_timeout</a> setting
       is available.
      </p>
      <p class="para">
       The <em>typemap</em> option is an array of type mappings.
       Type mapping is an array with keys <em>type_name</em>,
       <em>type_ns</em> (namespace URI), <em>from_xml</em>
       (callback accepting one string parameter) and <em>to_xml</em>
       (callback accepting one object parameter).
      </p>
      <p class="para">
       The <em>cache_wsdl</em> option is one of
       <strong><code>WSDL_CACHE_NONE</code></strong>,
       <strong><code>WSDL_CACHE_DISK</code></strong>,
       <strong><code>WSDL_CACHE_MEMORY</code></strong> or
       <strong><code>WSDL_CACHE_BOTH</code></strong>.
      </p>
      <p class="para">
       The <em>user_agent</em> option specifies string to use in
       <em>User-Agent</em> header.
      </p>
      <p class="para">
       The <em>stream_context</em> option is a <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>
       for <a href="context.html" class="link">context</a>.
      </p>
      <p class="para">
       The <em>features</em> option is a bitmask of
       <strong><code>SOAP_SINGLE_ELEMENT_ARRAYS</code></strong>,
       <strong><code>SOAP_USE_XSI_ARRAY_TYPE</code></strong>,
       <strong><code>SOAP_WAIT_ONE_WAY_CALLS</code></strong>.
      </p>
      <p class="para">
       The <em>keep_alive</em> option is a boolean value defining whether
       to send the <em>Connection: Keep-Alive</em> header or 
       <em>Connection: close</em>.
      </p>
      <p class="para">
       The <em>ssl_method</em> option is one of
       <strong><code>SOAP_SSL_METHOD_TLS</code></strong>,
       <strong><code>SOAP_SSL_METHOD_SSLv2</code></strong>,
       <strong><code>SOAP_SSL_METHOD_SSLv3</code></strong> or
       <strong><code>SOAP_SSL_METHOD_SSLv23</code></strong>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-soapclient.soapclient-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <span class="methodname"><strong>SoapClient::SoapClient()</strong></span> will generate an
   <strong><code>E_ERROR</code></strong> error if the <em>location</em> and
   <em>uri</em> options aren&#039;t provided in non-WSDL mode.
  </p>
  <p class="para">
   A <a href="class.soapfault.html" class="classname">SoapFault</a> exception will be thrown if the
   <em><code class="parameter">wsdl</code></em> URI cannot be loaded.
  </p>
 </div>


<div class="refsect1 changelog" id="refsect1-soapclient.soapclient-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.5.0</td>
       <td>
        New <em>ssl_method</em> option.
       </td>
      </tr>

      <tr>
       <td>5.4.0</td>
       <td>
        New <em>keep_alive</em> option.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-soapclient.soapclient-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5206">
    <p><strong>Example #1 <span class="function"><strong>SoapClient::SoapClient()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'soap_version'&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOAP_1_2</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'login'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"some_name"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'password'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"some_password"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'proxy_host'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxy_port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">8080</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'proxy_host'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxy_port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">8080</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxy_login'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"some_name"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'proxy_password'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"some_password"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'local_cert'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"cert_key.pem"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'location'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://localhost/soap.php"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'uri'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'location'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://localhost/soap.php"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'uri'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'style'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOAP_DOCUMENT</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'use'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOAP_LITERAL</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;<br />&nbsp;&nbsp;array(</span><span style="color: #DD0000">'compression'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOAP_COMPRESSION_ACCEPT&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">SOAP_COMPRESSION_GZIP</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'encoding'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">));<br /><br />class&nbsp;</span><span style="color: #0000BB">MyBook&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$title</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$author</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"books.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'classmap'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'book'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MyBook"</span><span style="color: #007700">)));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="soapclient.soapcall.html">SoapClient::__soapCall</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.soapserver.html">SoapServer</a></div>
 <div class="up"><a href="class.soapclient.html">SoapClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
